#!/bin/bash

GETH_VERSION=v1.8.3

DOCKER_NAME="geth-rink"
DOCKER_FLAGS="-it --rm"

while getopts ":dv:n:" opt; do
    case ${opt} in
        d)
            DOCKER_FLAGS+=" -d"
            ;;
        v)
            GETH_VERSION=$OPTARG
            ;;
        n)
            DOCKER_NAME=$OPTARG
            ;;
        \?)
            echo "Invalid Option: -$OPTARG";
            exit 1
            ;;
    esac
done
shift $((OPTIND -1))

docker run \
	--name $DOCKER_NAME \
	${DOCKER_FLAGS} \
	-v /data/ethereum/rinkeby:/root \
	-v $PWD/rinkeby.json:/genesis.json \
	-v $PWD/config-${GETH_VERSION}.toml:/config.toml \
        -p 8545:8545 \
        -p 30303:30303 \
        -p 8080:8080 \
	ethereum/client-go:${GETH_VERSION} $@

